<template>
	<view style="padding: 20rpx;background-color: #fff;">
		<head style="font-size: 40rpx;">基本资料</head>
		<u--form labelWidth='80' labelPosition="left" :model="model1" :rules="rules" ref="uForm">
			<u-form-item label="姓名" prop="userInfo.talentName" borderBottom ref="item1">
				<u--input v-model="model1.userInfo.talentName" placeholder="输入真实姓名" border="none"></u--input>
				
			</u-form-item>
			<u-form-item label="手机号码" prop="userInfo.phone" borderBottom ref="item1">
				<u--input v-model="model1.userInfo.phone" placeholder="输入手机号码" border="none"></u--input>
			
			</u-form-item>
			<u-form-item label="性别" prop="userInfo.sex" borderBottom @click="showSex = true;" ref="item1">
				<u--input v-model="model1.userInfo.sex" disabled disabledColor="#ffffff" placeholder="选择性别"
					border="none"></u--input>
				<u-icon slot="right" name="arrow-right"></u-icon>
			</u-form-item>
			<u-form-item label="身份证号" prop="userInfo.idCard" borderBottom ref="item1">
				<u--input v-model="model1.userInfo.idCard" placeholder="输入身份证号" border="none"></u--input>
				
			</u-form-item>
			<u-form-item label="地址" prop="userInfo.address" borderBottom ref="item1">
				<u--input v-model="model1.userInfo.address" placeholder="输入地址" border="none"></u--input>
				
			</u-form-item>
			<u-form-item label="期望岗位" prop="userInfo.expectationPostId" borderBottom ref="item1">
				<u--input v-model="model1.userInfo.expectationPostId" placeholder="输入期望岗位" border="none"></u--input>
				
			</u-form-item>
			<u-form-item label="期望薪资" prop="userInfo.expectationSalary" borderBottom ref="item1">
				<u--input v-model="model1.userInfo.expectationSalary" placeholder="输入期望薪资" border="none"></u--input>
			</u-form-item>
			<u-form-item label="备注" prop="userInfo.remark" borderBottom ref="item1">
				<u--textarea v-model="model1.userInfo.remark" placeholder="输入备注" border="none"></u--textarea>
			</u-form-item>
		</u--form>
		<u-button style="margin-top: 10px;" type="primary" text="确定" @click="submitForm"></u-button>
		<u-action-sheet :show="showSex" :actions="actions" title="请选择性别" @close="showSex = false" @select="sexSelect">
		</u-action-sheet>
	

	</view>
</template>

<script>
	import {
		addTalent
	} from '@/api/talent/talent.js'
	export default {
		data() {
			return {
				showSex: false,
				type: '',
				model1: {
					userInfo: {},
				},
				actions: [{
						name: '男',
					},
					{
						name: '女',
					},
					{
						name: '保密',
					},
				],
				rules: {
					'userInfo.name': {
						type: 'string',
						required: true,
						message: '请填写姓名',
						trigger: ['blur', 'change']
					},
					'userInfo.phone': {
						type: 'string',
						required: true,
						message: '请填写手机号',
						trigger: ['blur', 'change']
					},
				},
			}
		},
		onLoad(options) {
			if (this.model1.userInfo) {
				this.showSex = false
			}
			console.log(options.renCaiInfo, "options")
			if (options.renCaiInfo) {
				this.model1.userInfo = JSON.parse(decodeURIComponent(options.renCaiInfo))
				console.log(this.model1)
				// this.type = options.type
			}
		},
		methods: {
			formSubmit: function(e) {
				console.log('form发生了submit事件，携带数据为：' + JSON.stringify(e.detail.value))
				var formdata = e.detail.value
				uni.showModal({
					content: '表单数据内容：' + JSON.stringify(formdata),
					showCancel: false
				});
			},
			submitForm() {
				let res = addTalent(this.model1.userInfo)
				console.log(res)
				uni.showToast({
					title: '成功', // 提示的内容
					icon: 'success', // 使用内置的成功图标
					duration: 2000 // 提示框显示的时间，单位为毫秒
				})
			},
			sexSelect(e) {
				console.log(e)
				this.model1.userInfo.sex = e.name
				this.$refs.uForm.validateField('userInfo.sex')
			},
		}
	}
</script>

<style>
</style>